<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns the type ID (OID) for the corresponding field number</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.pg-field-table.html">« pg_field_table</a></li>
      <li style="float: right;"><a href="function.pg-field-type.html">pg_field_type »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.pgsql.html">PostgreSQL 函数</a></li>
    <li>Returns the type ID (OID) for the corresponding field number</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.pg-field-type-oid" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_field_type_oid</h1> 
  <p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pg_field_type_oid</span> &mdash; <span class="dc-title">
   Returns the type ID (OID) for the corresponding field number
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-field-type-oid-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pg_field_type_oid</strong></span>(<span class="methodparam"><span class="type"><a href="class.pgsql-result.html" class="type PgSql\Result">PgSql\Result</a></span> <code class="parameter">$result</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$field</code></span>): <span class="type"><span class="type">string</span>|<span class="type">int</span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>pg_field_type_oid()</strong></span> returns an integer containing the
   OID of the base type of the given <code class="parameter">field</code> in the
   given <code class="parameter">result</code> instance.
  </p>
  <p class="para">
    You can get more information about the field type by querying PostgreSQL&#039;s
    <code class="literal">pg_type</code> system table using the OID obtained with this function.
    The PostgreSQL <span class="function"><strong>format_type()</strong></span> function will convert a
    type OID into an SQL standard type name.
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    If the field uses a PostgreSQL domain (rather than a basic type), it is
    the OID of the domain&#039;s underlying type that is returned, rather than the OID
    of the domain itself.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-field-type-oid-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">result</code></dt>

     <dd>

      <p class="para">An <span class="classname"><a href="class.pgsql-result.html" class="classname">PgSql\Result</a></span> instance, returned by <span class="function"><a href="function.pg-query.html" class="function">pg_query()</a></span>,
<span class="function"><a href="function.pg-query-params.html" class="function">pg_query_params()</a></span> or <span class="function"><a href="function.pg-execute.html" class="function">pg_execute()</a></span>(among others).</p>
     </dd>

    
    
     <dt>
<code class="parameter">field</code></dt>

      <dd>

       <p class="para">
        Field number, starting from 0.
       </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-field-type-oid-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The OID of the field&#039;s base type.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.pg-field-type-oid-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  现在 <code class="parameter">result</code> 参数接受 <span class="classname"><a href="class.pgsql-result.html" class="classname">PgSql\Result</a></span>
  实例，之前接受 <a href="language.types.resource.html" class="link">资源(resource)</a>。
 </td>
</tr>

    </tbody>
   
  </table>

 </div>

 
 <div class="refsect1 examples" id="refsect1-function.pg-field-type-oid-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1911">
    <p><strong>示例 #1 Getting information about fields</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;$dbconn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">)&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Assume&nbsp;'title'&nbsp;is&nbsp;a&nbsp;varchar&nbsp;type<br />&nbsp;&nbsp;</span><span style="color: #0000BB">$res&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_query</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"select&nbsp;title&nbsp;from&nbsp;authors&nbsp;where&nbsp;author&nbsp;=&nbsp;'Orwell'"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Title&nbsp;field&nbsp;type&nbsp;OID:&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">pg_field_type_oid</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Title field type OID: 1043
</pre></div>
    </div>
   </div> 
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.pg-field-type-oid-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.pg-field-type.html" class="function" rel="rdfs-seeAlso">pg_field_type()</a> - 返回相应字段的类型名称</span></li>
    <li class="member"><span class="function"><a href="function.pg-field-prtlen.html" class="function" rel="rdfs-seeAlso">pg_field_prtlen()</a> - 返回打印出来的长度</span></li>
    <li class="member"><span class="function"><a href="function.pg-field-name.html" class="function" rel="rdfs-seeAlso">pg_field_name()</a> - 返回字段的名字</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>